{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import json\n",
    "import cv2 as cv\n",
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "from circum import xy_values\n",
    "import random"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "os.chdir(\"/home/kiprono/Documents/STELLENBOSCH UNIVERISTY/Masters by Research\\\n",
    "/Mask RCNN/Annotation projects/RR/train_images\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "with open(\"via_project_rr.json\",\"r\") as file:\n",
    "    data = file.read()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "data = json.loads(data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>filename</th>\n",
       "      <th>file_size</th>\n",
       "      <th>file_attributes</th>\n",
       "      <th>region_count</th>\n",
       "      <th>region_id</th>\n",
       "      <th>region_shape_attributes</th>\n",
       "      <th>region_attributes</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [filename, file_size, file_attributes, region_count, region_id, region_shape_attributes, region_attributes]\n",
       "Index: []"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "headers = ['filename', 'file_size', 'file_attributes', 'region_count', 'region_id',\n",
    "       'region_shape_attributes', 'region_attributes']\n",
    "meta_rr = pd.DataFrame(columns=headers)\n",
    "meta_rr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'filename': '0001-0001-11647-166-51.jpg',\n",
       " 'size': 74541,\n",
       " 'regions': [{'shape_attributes': {'name': 'circle',\n",
       "    'cx': 96,\n",
       "    'cy': 20,\n",
       "    'r': 24},\n",
       "   'region_attributes': {}},\n",
       "  {'shape_attributes': {'name': 'circle', 'cx': 80, 'cy': 54, 'r': 19},\n",
       "   'region_attributes': {}},\n",
       "  {'shape_attributes': {'name': 'circle', 'cx': 263, 'cy': 45, 'r': 14.45},\n",
       "   'region_attributes': {}},\n",
       "  {'shape_attributes': {'name': 'circle', 'cx': 261, 'cy': 74, 'r': 15},\n",
       "   'region_attributes': {}},\n",
       "  {'shape_attributes': {'name': 'circle', 'cx': 241, 'cy': 159, 'r': 12},\n",
       "   'region_attributes': {}},\n",
       "  {'shape_attributes': {'name': 'circle', 'cx': 218, 'cy': 162, 'r': 13},\n",
       "   'region_attributes': {}},\n",
       "  {'shape_attributes': {'name': 'circle', 'cx': 86, 'cy': 220, 'r': 15},\n",
       "   'region_attributes': {}},\n",
       "  {'shape_attributes': {'name': 'circle', 'cx': 60, 'cy': 244, 'r': 15},\n",
       "   'region_attributes': {}},\n",
       "  {'shape_attributes': {'name': 'circle', 'cx': 88, 'cy': 261, 'r': 11.321},\n",
       "   'region_attributes': {}},\n",
       "  {'shape_attributes': {'name': 'circle', 'cx': 112, 'cy': 255, 'r': 10.881},\n",
       "   'region_attributes': {}},\n",
       "  {'shape_attributes': {'name': 'circle', 'cx': 285, 'cy': 292, 'r': 13.297},\n",
       "   'region_attributes': {}},\n",
       "  {'shape_attributes': {'name': 'circle', 'cx': 269, 'cy': 310, 'r': 12},\n",
       "   'region_attributes': {}},\n",
       "  {'shape_attributes': {'name': 'circle', 'cx': 260, 'cy': 292, 'r': 12},\n",
       "   'region_attributes': {}},\n",
       "  {'shape_attributes': {'name': 'circle', 'cx': 12, 'cy': 361, 'r': 16},\n",
       "   'region_attributes': {}},\n",
       "  {'shape_attributes': {'name': 'circle', 'cx': 308, 'cy': 359, 'r': 14},\n",
       "   'region_attributes': {}},\n",
       "  {'shape_attributes': {'name': 'circle', 'cx': 349, 'cy': 357, 'r': 14},\n",
       "   'region_attributes': {}},\n",
       "  {'shape_attributes': {'name': 'circle', 'cx': 366, 'cy': 457, 'r': 12},\n",
       "   'region_attributes': {}},\n",
       "  {'shape_attributes': {'name': 'circle', 'cx': 382, 'cy': 486, 'r': 17},\n",
       "   'region_attributes': {}},\n",
       "  {'shape_attributes': {'name': 'circle', 'cx': 402, 'cy': 514, 'r': 14},\n",
       "   'region_attributes': {}},\n",
       "  {'shape_attributes': {'name': 'circle', 'cx': 450, 'cy': 533, 'r': 8},\n",
       "   'region_attributes': {}},\n",
       "  {'shape_attributes': {'name': 'circle', 'cx': 426, 'cy': 432, 'r': 10},\n",
       "   'region_attributes': {}}],\n",
       " 'file_attributes': {}}"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "i = 6\n",
    "one = list((list(data.values())[1]).values())[i]\n",
    "one"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0001-0001-11647-166-51.jpg\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>filename</th>\n",
       "      <th>file_size</th>\n",
       "      <th>file_attributes</th>\n",
       "      <th>region_count</th>\n",
       "      <th>region_id</th>\n",
       "      <th>region_shape_attributes</th>\n",
       "      <th>region_attributes</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0001-0001-11647-166-51.jpg</td>\n",
       "      <td>74541</td>\n",
       "      <td>{}</td>\n",
       "      <td>21</td>\n",
       "      <td>0</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [120, 119,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0001-0001-11647-166-51.jpg</td>\n",
       "      <td>74541</td>\n",
       "      <td>{}</td>\n",
       "      <td>21</td>\n",
       "      <td>1</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [99, 98, 9...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0001-0001-11647-166-51.jpg</td>\n",
       "      <td>74541</td>\n",
       "      <td>{}</td>\n",
       "      <td>21</td>\n",
       "      <td>2</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [277, 277,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0001-0001-11647-166-51.jpg</td>\n",
       "      <td>74541</td>\n",
       "      <td>{}</td>\n",
       "      <td>21</td>\n",
       "      <td>3</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [276, 275,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0001-0001-11647-166-51.jpg</td>\n",
       "      <td>74541</td>\n",
       "      <td>{}</td>\n",
       "      <td>21</td>\n",
       "      <td>4</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [253, 252,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>0001-0001-11647-166-51.jpg</td>\n",
       "      <td>74541</td>\n",
       "      <td>{}</td>\n",
       "      <td>21</td>\n",
       "      <td>5</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [231, 230,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>0001-0001-11647-166-51.jpg</td>\n",
       "      <td>74541</td>\n",
       "      <td>{}</td>\n",
       "      <td>21</td>\n",
       "      <td>6</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [101, 100,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>0001-0001-11647-166-51.jpg</td>\n",
       "      <td>74541</td>\n",
       "      <td>{}</td>\n",
       "      <td>21</td>\n",
       "      <td>7</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [75, 74, 7...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>0001-0001-11647-166-51.jpg</td>\n",
       "      <td>74541</td>\n",
       "      <td>{}</td>\n",
       "      <td>21</td>\n",
       "      <td>8</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [99, 99, 9...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>0001-0001-11647-166-51.jpg</td>\n",
       "      <td>74541</td>\n",
       "      <td>{}</td>\n",
       "      <td>21</td>\n",
       "      <td>9</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [122, 122,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>0001-0001-11647-166-51.jpg</td>\n",
       "      <td>74541</td>\n",
       "      <td>{}</td>\n",
       "      <td>21</td>\n",
       "      <td>10</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [298, 298,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>0001-0001-11647-166-51.jpg</td>\n",
       "      <td>74541</td>\n",
       "      <td>{}</td>\n",
       "      <td>21</td>\n",
       "      <td>11</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [281, 280,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>0001-0001-11647-166-51.jpg</td>\n",
       "      <td>74541</td>\n",
       "      <td>{}</td>\n",
       "      <td>21</td>\n",
       "      <td>12</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [272, 271,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>0001-0001-11647-166-51.jpg</td>\n",
       "      <td>74541</td>\n",
       "      <td>{}</td>\n",
       "      <td>21</td>\n",
       "      <td>13</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [28, 27, 2...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>0001-0001-11647-166-51.jpg</td>\n",
       "      <td>74541</td>\n",
       "      <td>{}</td>\n",
       "      <td>21</td>\n",
       "      <td>14</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [322, 321,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>0001-0001-11647-166-51.jpg</td>\n",
       "      <td>74541</td>\n",
       "      <td>{}</td>\n",
       "      <td>21</td>\n",
       "      <td>15</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [363, 362,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>0001-0001-11647-166-51.jpg</td>\n",
       "      <td>74541</td>\n",
       "      <td>{}</td>\n",
       "      <td>21</td>\n",
       "      <td>16</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [378, 377,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>0001-0001-11647-166-51.jpg</td>\n",
       "      <td>74541</td>\n",
       "      <td>{}</td>\n",
       "      <td>21</td>\n",
       "      <td>17</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [399, 398,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>0001-0001-11647-166-51.jpg</td>\n",
       "      <td>74541</td>\n",
       "      <td>{}</td>\n",
       "      <td>21</td>\n",
       "      <td>18</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [416, 415,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>0001-0001-11647-166-51.jpg</td>\n",
       "      <td>74541</td>\n",
       "      <td>{}</td>\n",
       "      <td>21</td>\n",
       "      <td>19</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [454, 454,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>0001-0001-11647-166-51.jpg</td>\n",
       "      <td>74541</td>\n",
       "      <td>{}</td>\n",
       "      <td>21</td>\n",
       "      <td>20</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [436, 435,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                      filename file_size file_attributes region_count  \\\n",
       "0   0001-0001-11647-166-51.jpg     74541              {}           21   \n",
       "1   0001-0001-11647-166-51.jpg     74541              {}           21   \n",
       "2   0001-0001-11647-166-51.jpg     74541              {}           21   \n",
       "3   0001-0001-11647-166-51.jpg     74541              {}           21   \n",
       "4   0001-0001-11647-166-51.jpg     74541              {}           21   \n",
       "5   0001-0001-11647-166-51.jpg     74541              {}           21   \n",
       "6   0001-0001-11647-166-51.jpg     74541              {}           21   \n",
       "7   0001-0001-11647-166-51.jpg     74541              {}           21   \n",
       "8   0001-0001-11647-166-51.jpg     74541              {}           21   \n",
       "9   0001-0001-11647-166-51.jpg     74541              {}           21   \n",
       "10  0001-0001-11647-166-51.jpg     74541              {}           21   \n",
       "11  0001-0001-11647-166-51.jpg     74541              {}           21   \n",
       "12  0001-0001-11647-166-51.jpg     74541              {}           21   \n",
       "13  0001-0001-11647-166-51.jpg     74541              {}           21   \n",
       "14  0001-0001-11647-166-51.jpg     74541              {}           21   \n",
       "15  0001-0001-11647-166-51.jpg     74541              {}           21   \n",
       "16  0001-0001-11647-166-51.jpg     74541              {}           21   \n",
       "17  0001-0001-11647-166-51.jpg     74541              {}           21   \n",
       "18  0001-0001-11647-166-51.jpg     74541              {}           21   \n",
       "19  0001-0001-11647-166-51.jpg     74541              {}           21   \n",
       "20  0001-0001-11647-166-51.jpg     74541              {}           21   \n",
       "\n",
       "   region_id                            region_shape_attributes  \\\n",
       "0          0  {'name': 'polygon', 'all_points_x': [120, 119,...   \n",
       "1          1  {'name': 'polygon', 'all_points_x': [99, 98, 9...   \n",
       "2          2  {'name': 'polygon', 'all_points_x': [277, 277,...   \n",
       "3          3  {'name': 'polygon', 'all_points_x': [276, 275,...   \n",
       "4          4  {'name': 'polygon', 'all_points_x': [253, 252,...   \n",
       "5          5  {'name': 'polygon', 'all_points_x': [231, 230,...   \n",
       "6          6  {'name': 'polygon', 'all_points_x': [101, 100,...   \n",
       "7          7  {'name': 'polygon', 'all_points_x': [75, 74, 7...   \n",
       "8          8  {'name': 'polygon', 'all_points_x': [99, 99, 9...   \n",
       "9          9  {'name': 'polygon', 'all_points_x': [122, 122,...   \n",
       "10        10  {'name': 'polygon', 'all_points_x': [298, 298,...   \n",
       "11        11  {'name': 'polygon', 'all_points_x': [281, 280,...   \n",
       "12        12  {'name': 'polygon', 'all_points_x': [272, 271,...   \n",
       "13        13  {'name': 'polygon', 'all_points_x': [28, 27, 2...   \n",
       "14        14  {'name': 'polygon', 'all_points_x': [322, 321,...   \n",
       "15        15  {'name': 'polygon', 'all_points_x': [363, 362,...   \n",
       "16        16  {'name': 'polygon', 'all_points_x': [378, 377,...   \n",
       "17        17  {'name': 'polygon', 'all_points_x': [399, 398,...   \n",
       "18        18  {'name': 'polygon', 'all_points_x': [416, 415,...   \n",
       "19        19  {'name': 'polygon', 'all_points_x': [454, 454,...   \n",
       "20        20  {'name': 'polygon', 'all_points_x': [436, 435,...   \n",
       "\n",
       "   region_attributes  \n",
       "0                 {}  \n",
       "1                 {}  \n",
       "2                 {}  \n",
       "3                 {}  \n",
       "4                 {}  \n",
       "5                 {}  \n",
       "6                 {}  \n",
       "7                 {}  \n",
       "8                 {}  \n",
       "9                 {}  \n",
       "10                {}  \n",
       "11                {}  \n",
       "12                {}  \n",
       "13                {}  \n",
       "14                {}  \n",
       "15                {}  \n",
       "16                {}  \n",
       "17                {}  \n",
       "18                {}  \n",
       "19                {}  \n",
       "20                {}  "
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "i = 6\n",
    "one = list((list(data.values())[1]).values())[i]\n",
    "a = one[\"filename\"] #filename\n",
    "print(a)\n",
    "b = one[\"size\"] #file_size\n",
    "c = \"{}\" #file_attributes\n",
    "d = len(one[\"regions\"])#region_count\n",
    "g = \"{}\" #region_attributes\n",
    "img = cv.imread(a)\n",
    "one_df = pd.DataFrame(columns=headers)\n",
    "for j in range(len(one[\"regions\"])):\n",
    "    xc = one[\"regions\"][j][\"shape_attributes\"][\"cx\"]#xc\n",
    "    yc = one[\"regions\"][j][\"shape_attributes\"][\"cy\"]#yc\n",
    "    r = one[\"regions\"][j][\"shape_attributes\"][\"r\"]#radius\n",
    "    t = {'name':'polygon','all_points_x':None,'all_points_y':None}\n",
    "    x,y = xy_values(xc,yc,r,img.shape[1],img.shape[0])\n",
    "    t['all_points_x']  = x\n",
    "    t['all_points_y'] = y\n",
    "    e = j #region_id\n",
    "    f = t #region_shape_attributes\n",
    "    row = [a,b,c,d,e,f,g]\n",
    "    one_df.loc[j] = row\n",
    "meta_rr = pd.concat([meta_rr,one_df],ignore_index=True)\n",
    "meta_rr"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## LOOP THROUGH ALL THE IMAGES - RR"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "368\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>filename</th>\n",
       "      <th>file_size</th>\n",
       "      <th>file_attributes</th>\n",
       "      <th>region_count</th>\n",
       "      <th>region_id</th>\n",
       "      <th>region_shape_attributes</th>\n",
       "      <th>region_attributes</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [filename, file_size, file_attributes, region_count, region_id, region_shape_attributes, region_attributes]\n",
       "Index: []"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "n = len(list((list(data.values())[1]).values()))\n",
    "print(n)\n",
    "meta_rr = pd.DataFrame(columns=headers)\n",
    "meta_rr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "for i in range(n):\n",
    "    one = list((list(data.values())[1]).values())[i]\n",
    "    a = one[\"filename\"] #filename\n",
    "    b = one[\"size\"] #file_size\n",
    "    c = \"{}\" #file_attributes\n",
    "    d = len(one[\"regions\"])#region_count\n",
    "    g = \"{}\" #region_attributes\n",
    "    img = cv.imread(a)\n",
    "    one_df = pd.DataFrame(columns=headers)\n",
    "    for j in range(len(one[\"regions\"])):\n",
    "        xc = one[\"regions\"][j][\"shape_attributes\"][\"cx\"]#xc\n",
    "        yc = one[\"regions\"][j][\"shape_attributes\"][\"cy\"]#yc\n",
    "        r = one[\"regions\"][j][\"shape_attributes\"][\"r\"]#radius\n",
    "        t = {'name':'polygon','all_points_x':None,'all_points_y':None}\n",
    "        x,y = xy_values(xc,yc,r,img.shape[0],img.shape[1])\n",
    "        t['all_points_x']  = x\n",
    "        t['all_points_y'] = y\n",
    "        e = j #region_id\n",
    "        f = t #region_shape_attributes\n",
    "        row = [a,b,c,d,e,f,g]\n",
    "        one_df.loc[j] = row\n",
    "    meta_rr = pd.concat([meta_rr,one_df],ignore_index=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>filename</th>\n",
       "      <th>file_size</th>\n",
       "      <th>file_attributes</th>\n",
       "      <th>region_count</th>\n",
       "      <th>region_id</th>\n",
       "      <th>region_shape_attributes</th>\n",
       "      <th>region_attributes</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0001-0001-11647-166-51.jpg</td>\n",
       "      <td>74541</td>\n",
       "      <td>{}</td>\n",
       "      <td>21</td>\n",
       "      <td>0</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [120, 119,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0001-0001-11647-166-51.jpg</td>\n",
       "      <td>74541</td>\n",
       "      <td>{}</td>\n",
       "      <td>21</td>\n",
       "      <td>1</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [99, 98, 9...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0001-0001-11647-166-51.jpg</td>\n",
       "      <td>74541</td>\n",
       "      <td>{}</td>\n",
       "      <td>21</td>\n",
       "      <td>2</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [277, 277,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0001-0001-11647-166-51.jpg</td>\n",
       "      <td>74541</td>\n",
       "      <td>{}</td>\n",
       "      <td>21</td>\n",
       "      <td>3</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [276, 275,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0001-0001-11647-166-51.jpg</td>\n",
       "      <td>74541</td>\n",
       "      <td>{}</td>\n",
       "      <td>21</td>\n",
       "      <td>4</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [253, 252,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>0001-0001-11647-166-51.jpg</td>\n",
       "      <td>74541</td>\n",
       "      <td>{}</td>\n",
       "      <td>21</td>\n",
       "      <td>5</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [231, 230,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>0001-0001-11647-166-51.jpg</td>\n",
       "      <td>74541</td>\n",
       "      <td>{}</td>\n",
       "      <td>21</td>\n",
       "      <td>6</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [101, 100,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>0001-0001-11647-166-51.jpg</td>\n",
       "      <td>74541</td>\n",
       "      <td>{}</td>\n",
       "      <td>21</td>\n",
       "      <td>7</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [75, 74, 7...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>0001-0001-11647-166-51.jpg</td>\n",
       "      <td>74541</td>\n",
       "      <td>{}</td>\n",
       "      <td>21</td>\n",
       "      <td>8</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [99, 99, 9...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>0001-0001-11647-166-51.jpg</td>\n",
       "      <td>74541</td>\n",
       "      <td>{}</td>\n",
       "      <td>21</td>\n",
       "      <td>9</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [122, 122,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>0001-0001-11647-166-51.jpg</td>\n",
       "      <td>74541</td>\n",
       "      <td>{}</td>\n",
       "      <td>21</td>\n",
       "      <td>10</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [298, 298,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>0001-0001-11647-166-51.jpg</td>\n",
       "      <td>74541</td>\n",
       "      <td>{}</td>\n",
       "      <td>21</td>\n",
       "      <td>11</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [281, 280,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>0001-0001-11647-166-51.jpg</td>\n",
       "      <td>74541</td>\n",
       "      <td>{}</td>\n",
       "      <td>21</td>\n",
       "      <td>12</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [272, 271,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>0001-0001-11647-166-51.jpg</td>\n",
       "      <td>74541</td>\n",
       "      <td>{}</td>\n",
       "      <td>21</td>\n",
       "      <td>13</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [28, 27, 2...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>0001-0001-11647-166-51.jpg</td>\n",
       "      <td>74541</td>\n",
       "      <td>{}</td>\n",
       "      <td>21</td>\n",
       "      <td>14</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [322, 321,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>0001-0001-11647-166-51.jpg</td>\n",
       "      <td>74541</td>\n",
       "      <td>{}</td>\n",
       "      <td>21</td>\n",
       "      <td>15</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [363, 362,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>0001-0001-11647-166-51.jpg</td>\n",
       "      <td>74541</td>\n",
       "      <td>{}</td>\n",
       "      <td>21</td>\n",
       "      <td>16</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [378, 377,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>0001-0001-11647-166-51.jpg</td>\n",
       "      <td>74541</td>\n",
       "      <td>{}</td>\n",
       "      <td>21</td>\n",
       "      <td>17</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [399, 398,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>0001-0001-11647-166-51.jpg</td>\n",
       "      <td>74541</td>\n",
       "      <td>{}</td>\n",
       "      <td>21</td>\n",
       "      <td>18</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [416, 415,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>0001-0001-11647-166-51.jpg</td>\n",
       "      <td>74541</td>\n",
       "      <td>{}</td>\n",
       "      <td>21</td>\n",
       "      <td>19</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [458, 457,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>0001-0001-11647-166-51.jpg</td>\n",
       "      <td>74541</td>\n",
       "      <td>{}</td>\n",
       "      <td>21</td>\n",
       "      <td>20</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [436, 435,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>0001-0001-12013-251-409.jpg</td>\n",
       "      <td>59225</td>\n",
       "      <td>{}</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [61, 60, 6...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>0001-0001-12013-251-409.jpg</td>\n",
       "      <td>59225</td>\n",
       "      <td>{}</td>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [45, 44, 4...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>0001-0001-12013-251-409.jpg</td>\n",
       "      <td>59225</td>\n",
       "      <td>{}</td>\n",
       "      <td>4</td>\n",
       "      <td>2</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [18, 17, 1...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>0001-0001-12013-251-409.jpg</td>\n",
       "      <td>59225</td>\n",
       "      <td>{}</td>\n",
       "      <td>4</td>\n",
       "      <td>3</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [161, 160,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>0001-0001-12014-253-337.jpg</td>\n",
       "      <td>56653</td>\n",
       "      <td>{}</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [225, 224,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>0001-0001-12014-253-337.jpg</td>\n",
       "      <td>56653</td>\n",
       "      <td>{}</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [302, 301,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>0001-0001-12014-272-396.jpg</td>\n",
       "      <td>59146</td>\n",
       "      <td>{}</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [22, 21, 2...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>0001-0001-12402-531-78.jpg</td>\n",
       "      <td>107941</td>\n",
       "      <td>{}</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [377, 376,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>0001-0001-12402-531-78.jpg</td>\n",
       "      <td>107941</td>\n",
       "      <td>{}</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [239, 238,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1948</th>\n",
       "      <td>0006-0005-1-128-0128.jpg</td>\n",
       "      <td>193628</td>\n",
       "      <td>{}</td>\n",
       "      <td>8</td>\n",
       "      <td>4</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [81, 80, 8...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1949</th>\n",
       "      <td>0006-0005-1-128-0128.jpg</td>\n",
       "      <td>193628</td>\n",
       "      <td>{}</td>\n",
       "      <td>8</td>\n",
       "      <td>5</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [310, 309,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1950</th>\n",
       "      <td>0006-0005-1-128-0128.jpg</td>\n",
       "      <td>193628</td>\n",
       "      <td>{}</td>\n",
       "      <td>8</td>\n",
       "      <td>6</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [591, 590,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1951</th>\n",
       "      <td>0006-0005-1-128-0128.jpg</td>\n",
       "      <td>193628</td>\n",
       "      <td>{}</td>\n",
       "      <td>8</td>\n",
       "      <td>7</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [647, 646,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1952</th>\n",
       "      <td>0006-0005-11646-140-81.jpg</td>\n",
       "      <td>94919</td>\n",
       "      <td>{}</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [350, 349,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1953</th>\n",
       "      <td>0006-0005-11646-140-81.jpg</td>\n",
       "      <td>94919</td>\n",
       "      <td>{}</td>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [281, 280,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1954</th>\n",
       "      <td>0006-0005-11646-140-81.jpg</td>\n",
       "      <td>94919</td>\n",
       "      <td>{}</td>\n",
       "      <td>4</td>\n",
       "      <td>2</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [128, 127,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1955</th>\n",
       "      <td>0006-0005-11646-140-81.jpg</td>\n",
       "      <td>94919</td>\n",
       "      <td>{}</td>\n",
       "      <td>4</td>\n",
       "      <td>3</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [51, 50, 5...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1956</th>\n",
       "      <td>0006-0006-11645-117-69.jpg</td>\n",
       "      <td>86383</td>\n",
       "      <td>{}</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [345, 344,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1957</th>\n",
       "      <td>0006-0006-11645-117-69.jpg</td>\n",
       "      <td>86383</td>\n",
       "      <td>{}</td>\n",
       "      <td>5</td>\n",
       "      <td>1</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [111, 110,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1958</th>\n",
       "      <td>0006-0006-11645-117-69.jpg</td>\n",
       "      <td>86383</td>\n",
       "      <td>{}</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [40, 39, 3...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1959</th>\n",
       "      <td>0006-0006-11645-117-69.jpg</td>\n",
       "      <td>86383</td>\n",
       "      <td>{}</td>\n",
       "      <td>5</td>\n",
       "      <td>3</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [351, 350,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1960</th>\n",
       "      <td>0006-0006-11645-117-69.jpg</td>\n",
       "      <td>86383</td>\n",
       "      <td>{}</td>\n",
       "      <td>5</td>\n",
       "      <td>4</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [396, 395,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1961</th>\n",
       "      <td>0006-0006-11645-126-177.jpg</td>\n",
       "      <td>126209</td>\n",
       "      <td>{}</td>\n",
       "      <td>13</td>\n",
       "      <td>0</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [122, 121,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1962</th>\n",
       "      <td>0006-0006-11645-126-177.jpg</td>\n",
       "      <td>126209</td>\n",
       "      <td>{}</td>\n",
       "      <td>13</td>\n",
       "      <td>1</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [442, 441,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1963</th>\n",
       "      <td>0006-0006-11645-126-177.jpg</td>\n",
       "      <td>126209</td>\n",
       "      <td>{}</td>\n",
       "      <td>13</td>\n",
       "      <td>2</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [446, 445,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1964</th>\n",
       "      <td>0006-0006-11645-126-177.jpg</td>\n",
       "      <td>126209</td>\n",
       "      <td>{}</td>\n",
       "      <td>13</td>\n",
       "      <td>3</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [262, 261,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1965</th>\n",
       "      <td>0006-0006-11645-126-177.jpg</td>\n",
       "      <td>126209</td>\n",
       "      <td>{}</td>\n",
       "      <td>13</td>\n",
       "      <td>4</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [285, 284,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1966</th>\n",
       "      <td>0006-0006-11645-126-177.jpg</td>\n",
       "      <td>126209</td>\n",
       "      <td>{}</td>\n",
       "      <td>13</td>\n",
       "      <td>5</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [268, 267,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1967</th>\n",
       "      <td>0006-0006-11645-126-177.jpg</td>\n",
       "      <td>126209</td>\n",
       "      <td>{}</td>\n",
       "      <td>13</td>\n",
       "      <td>6</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [251, 250,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1968</th>\n",
       "      <td>0006-0006-11645-126-177.jpg</td>\n",
       "      <td>126209</td>\n",
       "      <td>{}</td>\n",
       "      <td>13</td>\n",
       "      <td>7</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [282, 281,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1969</th>\n",
       "      <td>0006-0006-11645-126-177.jpg</td>\n",
       "      <td>126209</td>\n",
       "      <td>{}</td>\n",
       "      <td>13</td>\n",
       "      <td>8</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [288, 287,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1970</th>\n",
       "      <td>0006-0006-11645-126-177.jpg</td>\n",
       "      <td>126209</td>\n",
       "      <td>{}</td>\n",
       "      <td>13</td>\n",
       "      <td>9</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [167, 166,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1971</th>\n",
       "      <td>0006-0006-11645-126-177.jpg</td>\n",
       "      <td>126209</td>\n",
       "      <td>{}</td>\n",
       "      <td>13</td>\n",
       "      <td>10</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [167, 166,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1972</th>\n",
       "      <td>0006-0006-11645-126-177.jpg</td>\n",
       "      <td>126209</td>\n",
       "      <td>{}</td>\n",
       "      <td>13</td>\n",
       "      <td>11</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [66, 65, 6...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1973</th>\n",
       "      <td>0006-0006-11645-126-177.jpg</td>\n",
       "      <td>126209</td>\n",
       "      <td>{}</td>\n",
       "      <td>13</td>\n",
       "      <td>12</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [96, 95, 9...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1974</th>\n",
       "      <td>0006-0006-12014-253-337.jpg</td>\n",
       "      <td>60899</td>\n",
       "      <td>{}</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [123, 122,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1975</th>\n",
       "      <td>0006-0006-12384-483-145.jpg</td>\n",
       "      <td>84791</td>\n",
       "      <td>{}</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [105, 104,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1976</th>\n",
       "      <td>0006-0006-12384-483-145.jpg</td>\n",
       "      <td>84791</td>\n",
       "      <td>{}</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [138, 137,...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1977</th>\n",
       "      <td>0006-0006-12384-483-145.jpg</td>\n",
       "      <td>84791</td>\n",
       "      <td>{}</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>{'name': 'polygon', 'all_points_x': [26, 25, 2...</td>\n",
       "      <td>{}</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1978 rows × 7 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                         filename file_size file_attributes region_count  \\\n",
       "0      0001-0001-11647-166-51.jpg     74541              {}           21   \n",
       "1      0001-0001-11647-166-51.jpg     74541              {}           21   \n",
       "2      0001-0001-11647-166-51.jpg     74541              {}           21   \n",
       "3      0001-0001-11647-166-51.jpg     74541              {}           21   \n",
       "4      0001-0001-11647-166-51.jpg     74541              {}           21   \n",
       "5      0001-0001-11647-166-51.jpg     74541              {}           21   \n",
       "6      0001-0001-11647-166-51.jpg     74541              {}           21   \n",
       "7      0001-0001-11647-166-51.jpg     74541              {}           21   \n",
       "8      0001-0001-11647-166-51.jpg     74541              {}           21   \n",
       "9      0001-0001-11647-166-51.jpg     74541              {}           21   \n",
       "10     0001-0001-11647-166-51.jpg     74541              {}           21   \n",
       "11     0001-0001-11647-166-51.jpg     74541              {}           21   \n",
       "12     0001-0001-11647-166-51.jpg     74541              {}           21   \n",
       "13     0001-0001-11647-166-51.jpg     74541              {}           21   \n",
       "14     0001-0001-11647-166-51.jpg     74541              {}           21   \n",
       "15     0001-0001-11647-166-51.jpg     74541              {}           21   \n",
       "16     0001-0001-11647-166-51.jpg     74541              {}           21   \n",
       "17     0001-0001-11647-166-51.jpg     74541              {}           21   \n",
       "18     0001-0001-11647-166-51.jpg     74541              {}           21   \n",
       "19     0001-0001-11647-166-51.jpg     74541              {}           21   \n",
       "20     0001-0001-11647-166-51.jpg     74541              {}           21   \n",
       "21    0001-0001-12013-251-409.jpg     59225              {}            4   \n",
       "22    0001-0001-12013-251-409.jpg     59225              {}            4   \n",
       "23    0001-0001-12013-251-409.jpg     59225              {}            4   \n",
       "24    0001-0001-12013-251-409.jpg     59225              {}            4   \n",
       "25    0001-0001-12014-253-337.jpg     56653              {}            2   \n",
       "26    0001-0001-12014-253-337.jpg     56653              {}            2   \n",
       "27    0001-0001-12014-272-396.jpg     59146              {}            1   \n",
       "28     0001-0001-12402-531-78.jpg    107941              {}            2   \n",
       "29     0001-0001-12402-531-78.jpg    107941              {}            2   \n",
       "...                           ...       ...             ...          ...   \n",
       "1948     0006-0005-1-128-0128.jpg    193628              {}            8   \n",
       "1949     0006-0005-1-128-0128.jpg    193628              {}            8   \n",
       "1950     0006-0005-1-128-0128.jpg    193628              {}            8   \n",
       "1951     0006-0005-1-128-0128.jpg    193628              {}            8   \n",
       "1952   0006-0005-11646-140-81.jpg     94919              {}            4   \n",
       "1953   0006-0005-11646-140-81.jpg     94919              {}            4   \n",
       "1954   0006-0005-11646-140-81.jpg     94919              {}            4   \n",
       "1955   0006-0005-11646-140-81.jpg     94919              {}            4   \n",
       "1956   0006-0006-11645-117-69.jpg     86383              {}            5   \n",
       "1957   0006-0006-11645-117-69.jpg     86383              {}            5   \n",
       "1958   0006-0006-11645-117-69.jpg     86383              {}            5   \n",
       "1959   0006-0006-11645-117-69.jpg     86383              {}            5   \n",
       "1960   0006-0006-11645-117-69.jpg     86383              {}            5   \n",
       "1961  0006-0006-11645-126-177.jpg    126209              {}           13   \n",
       "1962  0006-0006-11645-126-177.jpg    126209              {}           13   \n",
       "1963  0006-0006-11645-126-177.jpg    126209              {}           13   \n",
       "1964  0006-0006-11645-126-177.jpg    126209              {}           13   \n",
       "1965  0006-0006-11645-126-177.jpg    126209              {}           13   \n",
       "1966  0006-0006-11645-126-177.jpg    126209              {}           13   \n",
       "1967  0006-0006-11645-126-177.jpg    126209              {}           13   \n",
       "1968  0006-0006-11645-126-177.jpg    126209              {}           13   \n",
       "1969  0006-0006-11645-126-177.jpg    126209              {}           13   \n",
       "1970  0006-0006-11645-126-177.jpg    126209              {}           13   \n",
       "1971  0006-0006-11645-126-177.jpg    126209              {}           13   \n",
       "1972  0006-0006-11645-126-177.jpg    126209              {}           13   \n",
       "1973  0006-0006-11645-126-177.jpg    126209              {}           13   \n",
       "1974  0006-0006-12014-253-337.jpg     60899              {}            1   \n",
       "1975  0006-0006-12384-483-145.jpg     84791              {}            3   \n",
       "1976  0006-0006-12384-483-145.jpg     84791              {}            3   \n",
       "1977  0006-0006-12384-483-145.jpg     84791              {}            3   \n",
       "\n",
       "     region_id                            region_shape_attributes  \\\n",
       "0            0  {'name': 'polygon', 'all_points_x': [120, 119,...   \n",
       "1            1  {'name': 'polygon', 'all_points_x': [99, 98, 9...   \n",
       "2            2  {'name': 'polygon', 'all_points_x': [277, 277,...   \n",
       "3            3  {'name': 'polygon', 'all_points_x': [276, 275,...   \n",
       "4            4  {'name': 'polygon', 'all_points_x': [253, 252,...   \n",
       "5            5  {'name': 'polygon', 'all_points_x': [231, 230,...   \n",
       "6            6  {'name': 'polygon', 'all_points_x': [101, 100,...   \n",
       "7            7  {'name': 'polygon', 'all_points_x': [75, 74, 7...   \n",
       "8            8  {'name': 'polygon', 'all_points_x': [99, 99, 9...   \n",
       "9            9  {'name': 'polygon', 'all_points_x': [122, 122,...   \n",
       "10          10  {'name': 'polygon', 'all_points_x': [298, 298,...   \n",
       "11          11  {'name': 'polygon', 'all_points_x': [281, 280,...   \n",
       "12          12  {'name': 'polygon', 'all_points_x': [272, 271,...   \n",
       "13          13  {'name': 'polygon', 'all_points_x': [28, 27, 2...   \n",
       "14          14  {'name': 'polygon', 'all_points_x': [322, 321,...   \n",
       "15          15  {'name': 'polygon', 'all_points_x': [363, 362,...   \n",
       "16          16  {'name': 'polygon', 'all_points_x': [378, 377,...   \n",
       "17          17  {'name': 'polygon', 'all_points_x': [399, 398,...   \n",
       "18          18  {'name': 'polygon', 'all_points_x': [416, 415,...   \n",
       "19          19  {'name': 'polygon', 'all_points_x': [458, 457,...   \n",
       "20          20  {'name': 'polygon', 'all_points_x': [436, 435,...   \n",
       "21           0  {'name': 'polygon', 'all_points_x': [61, 60, 6...   \n",
       "22           1  {'name': 'polygon', 'all_points_x': [45, 44, 4...   \n",
       "23           2  {'name': 'polygon', 'all_points_x': [18, 17, 1...   \n",
       "24           3  {'name': 'polygon', 'all_points_x': [161, 160,...   \n",
       "25           0  {'name': 'polygon', 'all_points_x': [225, 224,...   \n",
       "26           1  {'name': 'polygon', 'all_points_x': [302, 301,...   \n",
       "27           0  {'name': 'polygon', 'all_points_x': [22, 21, 2...   \n",
       "28           0  {'name': 'polygon', 'all_points_x': [377, 376,...   \n",
       "29           1  {'name': 'polygon', 'all_points_x': [239, 238,...   \n",
       "...        ...                                                ...   \n",
       "1948         4  {'name': 'polygon', 'all_points_x': [81, 80, 8...   \n",
       "1949         5  {'name': 'polygon', 'all_points_x': [310, 309,...   \n",
       "1950         6  {'name': 'polygon', 'all_points_x': [591, 590,...   \n",
       "1951         7  {'name': 'polygon', 'all_points_x': [647, 646,...   \n",
       "1952         0  {'name': 'polygon', 'all_points_x': [350, 349,...   \n",
       "1953         1  {'name': 'polygon', 'all_points_x': [281, 280,...   \n",
       "1954         2  {'name': 'polygon', 'all_points_x': [128, 127,...   \n",
       "1955         3  {'name': 'polygon', 'all_points_x': [51, 50, 5...   \n",
       "1956         0  {'name': 'polygon', 'all_points_x': [345, 344,...   \n",
       "1957         1  {'name': 'polygon', 'all_points_x': [111, 110,...   \n",
       "1958         2  {'name': 'polygon', 'all_points_x': [40, 39, 3...   \n",
       "1959         3  {'name': 'polygon', 'all_points_x': [351, 350,...   \n",
       "1960         4  {'name': 'polygon', 'all_points_x': [396, 395,...   \n",
       "1961         0  {'name': 'polygon', 'all_points_x': [122, 121,...   \n",
       "1962         1  {'name': 'polygon', 'all_points_x': [442, 441,...   \n",
       "1963         2  {'name': 'polygon', 'all_points_x': [446, 445,...   \n",
       "1964         3  {'name': 'polygon', 'all_points_x': [262, 261,...   \n",
       "1965         4  {'name': 'polygon', 'all_points_x': [285, 284,...   \n",
       "1966         5  {'name': 'polygon', 'all_points_x': [268, 267,...   \n",
       "1967         6  {'name': 'polygon', 'all_points_x': [251, 250,...   \n",
       "1968         7  {'name': 'polygon', 'all_points_x': [282, 281,...   \n",
       "1969         8  {'name': 'polygon', 'all_points_x': [288, 287,...   \n",
       "1970         9  {'name': 'polygon', 'all_points_x': [167, 166,...   \n",
       "1971        10  {'name': 'polygon', 'all_points_x': [167, 166,...   \n",
       "1972        11  {'name': 'polygon', 'all_points_x': [66, 65, 6...   \n",
       "1973        12  {'name': 'polygon', 'all_points_x': [96, 95, 9...   \n",
       "1974         0  {'name': 'polygon', 'all_points_x': [123, 122,...   \n",
       "1975         0  {'name': 'polygon', 'all_points_x': [105, 104,...   \n",
       "1976         1  {'name': 'polygon', 'all_points_x': [138, 137,...   \n",
       "1977         2  {'name': 'polygon', 'all_points_x': [26, 25, 2...   \n",
       "\n",
       "     region_attributes  \n",
       "0                   {}  \n",
       "1                   {}  \n",
       "2                   {}  \n",
       "3                   {}  \n",
       "4                   {}  \n",
       "5                   {}  \n",
       "6                   {}  \n",
       "7                   {}  \n",
       "8                   {}  \n",
       "9                   {}  \n",
       "10                  {}  \n",
       "11                  {}  \n",
       "12                  {}  \n",
       "13                  {}  \n",
       "14                  {}  \n",
       "15                  {}  \n",
       "16                  {}  \n",
       "17                  {}  \n",
       "18                  {}  \n",
       "19                  {}  \n",
       "20                  {}  \n",
       "21                  {}  \n",
       "22                  {}  \n",
       "23                  {}  \n",
       "24                  {}  \n",
       "25                  {}  \n",
       "26                  {}  \n",
       "27                  {}  \n",
       "28                  {}  \n",
       "29                  {}  \n",
       "...                ...  \n",
       "1948                {}  \n",
       "1949                {}  \n",
       "1950                {}  \n",
       "1951                {}  \n",
       "1952                {}  \n",
       "1953                {}  \n",
       "1954                {}  \n",
       "1955                {}  \n",
       "1956                {}  \n",
       "1957                {}  \n",
       "1958                {}  \n",
       "1959                {}  \n",
       "1960                {}  \n",
       "1961                {}  \n",
       "1962                {}  \n",
       "1963                {}  \n",
       "1964                {}  \n",
       "1965                {}  \n",
       "1966                {}  \n",
       "1967                {}  \n",
       "1968                {}  \n",
       "1969                {}  \n",
       "1970                {}  \n",
       "1971                {}  \n",
       "1972                {}  \n",
       "1973                {}  \n",
       "1974                {}  \n",
       "1975                {}  \n",
       "1976                {}  \n",
       "1977                {}  \n",
       "\n",
       "[1978 rows x 7 columns]"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "meta_rr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## ROUGH SPACE"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [],
   "source": [
    "images_indir = os.listdir(os.getcwd())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [],
   "source": [
    "for img in images_indir:\n",
    "    if img not in images_annotated and img.startswith(\"via\")==False:\n",
    "        pass\n",
    "        #os.remove(img)\n",
    "    else:\n",
    "        pass\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
